package org.example.lc;

import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.*;

public class p11 {
    /**
     * area = w*h
     *          = (j-i)*min(height[i],height[j])
     *
     */
    class Solution {
        public int maxArea(int[] height) {

//            int[][] mem = new int[height.length][height.length];
            int maxArea=-1;
            for(int i =0;i<height.length;i+=1) {
                for(int j=i+1;j<height.length;j+=1) {
                    int tempArea = (j-i)*Math.min(height[i],height[j]);
                    if(tempArea>maxArea) {
                        maxArea = tempArea;
                    }
                }
            }
            return maxArea;
        }
    }
    @Test
    public void t1() {
        assertEquals(49,new Solution().maxArea(new int[]{1,8,6,2,5,4,8,3,7}));
    }
    @Test
    public void t2() {
        assertEquals(1,new Solution().maxArea(new int[]{1,1}));
    }
}
